package com.tea.funct.service.impl;

import com.tea.common.model.WxUser;
import com.tea.common.utils.DateUtils;
import com.tea.funct.domain.TeaMember;
import com.tea.funct.mapper.TeaMemberMapper;
import com.tea.funct.service.ITeaMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员管理Service业务层处理
 *
 * @author Sophia
 * @date 2024-05-25
 */
@Service
public class TeaMemberServiceImpl implements ITeaMemberService {
    @Autowired
    private TeaMemberMapper teaMemberMapper;

    /**
     * 查询会员管理
     *
     * @param id 会员管理主键
     * @return 会员管理
     */
    @Override
    public TeaMember selectTeaMemberById(Long id) {
        return teaMemberMapper.selectTeaMemberById(id);
    }

    /**
     * 查询会员管理列表
     *
     * @param teaMember 会员管理
     * @return 会员管理
     */
    @Override
    public List<TeaMember> selectTeaMemberList(TeaMember teaMember) {
        return teaMemberMapper.selectTeaMemberList(teaMember);
    }

    /**
     * 新增会员管理
     *
     * @param teaMember 会员管理
     * @return 结果
     */
    @Override
    public int insertTeaMember(TeaMember teaMember) {
        teaMember.setCreateTime(DateUtils.getNowDate());
        return teaMemberMapper.insertTeaMember(teaMember);
    }

    /**
     * 修改会员管理
     *
     * @param teaMember 会员管理
     * @return 结果
     */
    @Override
    public int updateTeaMember(TeaMember teaMember) {
        teaMember.setUpdateTime(DateUtils.getNowDate());
        return teaMemberMapper.updateTeaMember(teaMember);
    }

    /**
     * 批量删除会员管理
     *
     * @param ids 需要删除的会员管理主键
     * @return 结果
     */
    @Override
    public int deleteTeaMemberByIds(Long[] ids) {
        return teaMemberMapper.deleteTeaMemberByIds(ids);
    }

    /**
     * 删除会员管理信息
     *
     * @param id 会员管理主键
     * @return 结果
     */
    @Override
    public int deleteTeaMemberById(Long id) {
        return teaMemberMapper.deleteTeaMemberById(id);
    }

    @Override
    public TeaMember selectTeaMemberByUserId(Long userId) {
        return teaMemberMapper.selectTeaMemberByUserId(userId);
    }

    @Override
    public TeaMember selectTeaMemberByReferralCode(String referralCode) {
        return teaMemberMapper.selectTeaMemberByReferralCode(referralCode);
    }

    @Override
    public List<WxUser> selectAllWxUserList() {
        return teaMemberMapper.selectAllWxUserList();
    }

    @Override
    public Integer getInvitationUserData(Long userId) {
        return teaMemberMapper.getInvitationUserData(userId);
    }
}
